<template>
  <div class="ad-container">
    <div class="ad-item" v-for="(ad, index) in ads" :key="index">
      <div class="ad-label">广告</div>
      <img :src="ad.src" :alt="ad.alt">
    </div>
  </div>
</template>

<script>
export default {
  name: 'AdvertisementT',
  data() {
    return {
      ads: [
        { src: 'https://picsum.photos/360/200?random=3', alt: '广告1' },
        { src: 'https://picsum.photos/360/200?random=2', alt: '广告2' },
      ]
    }
  }
}
</script>

<style scoped>
.ad-container {
  margin-top: 40px;
  overflow: hidden;
  display: inline-flex;
  flex-direction: column;
  gap: 16px;
}

.ad-item {
  position: relative; /* 为绝对定位的子元素提供参考 */
  height: calc(100% / 3);
  border-radius: 10px;
  overflow: hidden; /* 防止放大的图片溢出容器 */
}

.ad-label {
  position: absolute; /* 绝对定位到左上角 */
  top: 10px;
  left: 10px;
  background-color: rgba(0, 0, 0, 0.6); /* 半透明背景 */
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 1; /* 确保显示在图片上方 */
}

.ad-item img {
  border-radius: 10px;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease; /* 添加过渡效果 */
}

.ad-item img:hover {
  transform: scale(1.1); /* 鼠标悬停时放大图片 */
}
</style>    